{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "开始计算中继节点的Oblivious方案\n",
      "cplex: 38.0, spf: 68.4, online: 54.4\n",
      "清除Alpha\n",
      "cplex: 37.0, spf: 65.0, online: 49.8\n",
      "清除Alpha\n",
      "cplex: 38.166666666666664, spf: 69.6, online: 49.4\n",
      "清除Alpha\n",
      "cplex: 38.91611502150133, spf: 56.5, online: 54.4\n",
      "清除Alpha\n",
      "cplex: 36.8, spf: 59.4, online: 51.8\n",
      "清除Alpha\n",
      "cplex: 32.20949349195476, spf: 92.0, online: 54.8\n",
      "清除Alpha\n",
      "cplex: 39.333333333333336, spf: 62.166666666666664, online: 47.6\n",
      "清除Alpha\n",
      "cplex: 38.46919211313399, spf: 57.166666666666664, online: 49.2\n",
      "清除Alpha\n",
      "cplex: 38.42857142857143, spf: 86.85714285714286, online: 48.2\n",
      "清除Alpha\n",
      "cplex: 28.594190058659034, spf: 70.16666666666667, online: 53.0\n",
      "清除Alpha\n",
      "cplex: 39.87608957878564, spf: 53.2, online: 52.4\n",
      "清除Alpha\n",
      "cplex: 30.218754537327072, spf: 49.0, online: 50.2\n",
      "清除Alpha\n",
      "cplex: 37.85230990088183, spf: 65.33333333333333, online: 53.4\n",
      "清除Alpha\n",
      "cplex: 32.0, spf: 63.2, online: 54.4\n",
      "清除Alpha\n",
      "cplex: 30.857142857142858, spf: 56.0, online: 56.0\n",
      "清除Alpha\n",
      "cplex: 36.18181818181818, spf: 66.83333333333333, online: 50.0\n",
      "清除Alpha\n",
      "cplex: 32.49349061456591, spf: 65.4, online: 48.4\n",
      "清除Alpha\n",
      "cplex: 35.176459320610896, spf: 59.833333333333336, online: 55.6\n",
      "清除Alpha\n",
      "cplex: 43.0, spf: 56.833333333333336, online: 51.0\n",
      "清除Alpha\n",
      "cplex: 36.9125180374671, spf: 78.66666666666667, online: 55.4\n",
      "清除Alpha\n",
      "开始计算中继节点的Oblivious方案\n",
      "666\n",
      "cplex: 19.849372568507814, spf: 43.833333333333336, online: 62.2\n",
      "清除Alpha\n",
      "cplex: 20.636363636363637, spf: 43.6, online: 58.8\n",
      "清除Alpha\n",
      "cplex: 21.49788666100168, spf: 38.142857142857146, online: 63.6\n",
      "清除Alpha\n",
      "cplex: 19.470588235294116, spf: 57.42857142857143, online: 61.0\n",
      "清除Alpha\n",
      "cplex: 18.862153290750573, spf: 54.2, online: 59.2\n",
      "清除Alpha\n",
      "cplex: 22.8, spf: 50.833333333333336, online: 54.6\n",
      "清除Alpha\n",
      "cplex: 27.0, spf: 71.8, online: 76.2\n",
      "清除Alpha\n",
      "cplex: 17.800266025254018, spf: 44.22222222222222, online: 60.2\n",
      "清除Alpha\n",
      "cplex: 28.653765152600172, spf: 70.2, online: 63.2\n",
      "清除Alpha\n",
      "cplex: 22.625, spf: 44.166666666666664, online: 59.0\n",
      "清除Alpha\n",
      "cplex: 24.583333333333332, spf: 60.8, online: 64.2\n",
      "清除Alpha\n",
      "cplex: 23.857142857142858, spf: 52.57142857142857, online: 60.2\n",
      "清除Alpha\n",
      "cplex: 24.666666666666668, spf: 86.0, online: 63.4\n",
      "清除Alpha\n",
      "cplex: 18.857142857142858, spf: 56.666666666666664, online: 61.2\n",
      "清除Alpha\n",
      "cplex: 21.5, spf: 58.4, online: 65.8\n",
      "清除Alpha\n",
      "cplex: 23.666666666666668, spf: 66.0, online: 62.8\n",
      "清除Alpha\n",
      "cplex: 20.25, spf: 52.2, online: 60.0\n",
      "清除Alpha\n",
      "cplex: 23.25, spf: 40.833333333333336, online: 57.2\n",
      "清除Alpha\n",
      "cplex: 19.444444444444443, spf: 72.2, online: 64.6\n",
      "清除Alpha\n",
      "cplex: 20.375, spf: 56.2, online: 65.8\n",
      "清除Alpha\n",
      "开始计算中继节点的Oblivious方案\n",
      "666\n",
      "cplex: 13.833333333333334, spf: 43.714285714285715, online: 68.6\n",
      "清除Alpha\n",
      "cplex: 16.30546099609808, spf: 41.714285714285715, online: 59.8\n",
      "清除Alpha\n",
      "cplex: 14.258978786000029, spf: 44.888888888888886, online: 63.6\n",
      "清除Alpha\n",
      "cplex: 17.714285714285715, spf: 46.666666666666664, online: 68.2\n",
      "清除Alpha\n",
      "cplex: 15.586795845854194, spf: 46.142857142857146, online: 63.8\n",
      "清除Alpha\n",
      "cplex: 14.636363636363637, spf: 52.5, online: 73.0\n",
      "清除Alpha\n",
      "cplex: 15.588235294117647, spf: 52.0, online: 53.0\n",
      "清除Alpha\n",
      "cplex: 17.321671610789014, spf: 56.0, online: 59.4\n",
      "清除Alpha\n",
      "cplex: 17.25625957222766, spf: 36.285714285714285, online: 61.2\n",
      "清除Alpha\n",
      "cplex: 17.117165286237338, spf: 33.857142857142854, online: 63.4\n",
      "清除Alpha\n",
      "cplex: 21.333333333333332, spf: 47.833333333333336, online: 79.4\n",
      "清除Alpha\n",
      "cplex: 14.571428571428571, spf: 37.0, online: 62.4\n",
      "清除Alpha\n",
      "cplex: 19.0, spf: 47.857142857142854, online: 62.2\n",
      "清除Alpha\n",
      "cplex: 13.77225113659603, spf: 51.714285714285715, online: 58.6\n",
      "清除Alpha\n",
      "cplex: 23.5, spf: 40.285714285714285, online: 72.0\n",
      "清除Alpha\n",
      "cplex: 25.833333333333332, spf: 41.57142857142857, online: 59.4\n",
      "清除Alpha\n",
      "cplex: 13.514694726976773, spf: 52.0, online: 60.8\n",
      "清除Alpha\n",
      "cplex: 14.141692687680571, spf: 41.2, online: 62.6\n",
      "清除Alpha\n",
      "cplex: 14.274455587918515, spf: 63.666666666666664, online: 70.0\n",
      "清除Alpha\n",
      "cplex: 20.59090909090909, spf: 39.714285714285715, online: 76.6\n",
      "清除Alpha\n",
      "开始计算中继节点的Oblivious方案\n",
      "666\n",
      "cplex: 18.142857142857142, spf: 34.714285714285715, online: 69.6\n",
      "清除Alpha\n",
      "cplex: 18.6, spf: 41.42857142857143, online: 68.6\n",
      "清除Alpha\n",
      "cplex: 11.954046162119125, spf: 39.714285714285715, online: 82.8\n",
      "清除Alpha\n",
      "cplex: 16.0, spf: 35.4, online: 78.0\n",
      "清除Alpha\n",
      "cplex: 20.22222222222222, spf: 29.4, online: 74.2\n",
      "清除Alpha\n",
      "cplex: 14.6, spf: 35.0, online: 69.0\n",
      "清除Alpha\n",
      "cplex: 12.578947368421053, spf: 40.0, online: 73.8\n",
      "清除Alpha\n",
      "cplex: 17.428571428571427, spf: 37.4, online: 78.2\n",
      "清除Alpha\n",
      "cplex: 13.411764705882353, spf: 27.8, online: 70.0\n",
      "清除Alpha\n",
      "cplex: 17.3, spf: 20.61111111111111, online: 69.4\n",
      "清除Alpha\n",
      "cplex: 20.333333333333332, spf: 34.57142857142857, online: 83.0\n",
      "清除Alpha\n",
      "cplex: 15.11111111111111, spf: 29.77777777777778, online: 93.6\n",
      "清除Alpha\n",
      "cplex: 13.0, spf: 38.0, online: 91.0\n",
      "清除Alpha\n",
      "cplex: 20.4, spf: 27.692307692307693, online: 78.6\n",
      "清除Alpha\n",
      "cplex: 17.285714285714285, spf: 39.42857142857143, online: 75.2\n",
      "清除Alpha\n",
      "cplex: 12.0, spf: 35.666666666666664, online: 86.4\n",
      "清除Alpha\n",
      "cplex: 14.064122727694645, spf: 45.8, online: 73.4\n",
      "清除Alpha\n",
      "cplex: 23.1, spf: 58.4, online: 76.2\n",
      "清除Alpha\n",
      "cplex: 15.0, spf: 32.2, online: 70.6\n",
      "清除Alpha\n",
      "cplex: 14.88888888888889, spf: 41.55555555555556, online: 95.4\n",
      "清除Alpha\n",
      "开始计算中继节点的Oblivious方案\n",
      "666\n",
      "cplex: 12.0, spf: 47.285714285714285, online: 85.66666666666667\n",
      "清除Alpha\n",
      "cplex: 11.875, spf: 55.8, online: 88.6\n",
      "清除Alpha\n",
      "cplex: 8.366666666666667, spf: 46.0, online: 77.0\n",
      "清除Alpha\n",
      "cplex: 9.652173913043478, spf: 81.2, online: 83.8\n",
      "清除Alpha\n",
      "cplex: 9.195720883491322, spf: 55.714285714285715, online: 85.2\n",
      "清除Alpha\n",
      "cplex: 8.866666666666667, spf: 39.5, online: 77.4\n",
      "清除Alpha\n",
      "cplex: 8.8953685040054, spf: 50.833333333333336, online: 86.4\n",
      "清除Alpha\n",
      "cplex: 11.0, spf: 78.0, online: 94.2\n",
      "清除Alpha\n",
      "cplex: 10.434782608695652, spf: 77.33333333333333, online: 90.4\n",
      "清除Alpha\n",
      "cplex: 9.0282337120297, spf: 38.875, online: 86.2\n",
      "清除Alpha\n",
      "cplex: 11.0, spf: 59.42857142857143, online: 79.2\n",
      "清除Alpha\n",
      "cplex: 10.916666666666666, spf: 34.714285714285715, online: 82.4\n",
      "清除Alpha\n",
      "cplex: 10.714342678435672, spf: 67.42857142857143, online: 81.4\n",
      "清除Alpha\n",
      "cplex: 9.245901639344263, spf: 55.333333333333336, online: 88.4\n",
      "清除Alpha\n",
      "cplex: 10.098039215686274, spf: 49.666666666666664, online: 81.4\n",
      "清除Alpha\n",
      "cplex: 11.695652173913043, spf: 40.75, online: 86.4\n",
      "清除Alpha\n",
      "cplex: 8.86953672551478, spf: 76.42857142857143, online: 101.4\n",
      "清除Alpha\n",
      "cplex: 11.032786885245901, spf: 70.2, online: 84.0\n",
      "清除Alpha\n",
      "cplex: 11.666666666666666, spf: 39.4, online: 97.8\n",
      "清除Alpha\n",
      "cplex: 10.76923076923077, spf: 68.0, online: 84.2\n",
      "清除Alpha\n",
      "开始计算中继节点的Oblivious方案\n",
      "666\n",
      "cplex: 10.636363636363637, spf: 79.4, online: 87.2\n",
      "清除Alpha\n",
      "cplex: 9.826444155371728, spf: 63.0, online: 100.4\n",
      "清除Alpha\n",
      "cplex: 17.46153846153846, spf: 41.0, online: 95.6\n",
      "清除Alpha\n",
      "cplex: 8.3, spf: 50.4, online: 89.8\n",
      "清除Alpha\n",
      "cplex: 14.0, spf: 49.2, online: 85.6\n",
      "清除Alpha\n",
      "cplex: 7.863755401382801, spf: 60.2, online: 91.8\n",
      "清除Alpha\n",
      "cplex: 10.9, spf: 32.166666666666664, online: 99.6\n",
      "清除Alpha\n",
      "cplex: 8.26086956521739, spf: 53.166666666666664, online: 87.8\n",
      "清除Alpha\n",
      "cplex: 11.0, spf: 41.142857142857146, online: 92.6\n",
      "清除Alpha\n",
      "cplex: 9.708333333333334, spf: 77.8, online: 95.6\n",
      "清除Alpha\n",
      "cplex: 9.105263157894736, spf: 51.6, online: 84.0\n",
      "清除Alpha\n",
      "cplex: 13.9, spf: 67.2, online: 94.6\n",
      "清除Alpha\n",
      "cplex: 10.85, spf: 81.6, online: 104.0\n",
      "清除Alpha\n",
      "cplex: 12.28, spf: 57.2, online: 104.2\n",
      "清除Alpha\n",
      "cplex: 10.444444444444445, spf: 59.0, online: 105.2\n",
      "清除Alpha\n",
      "cplex: 13.4, spf: 31.428571428571427, online: 91.8\n",
      "清除Alpha\n",
      "cplex: 11.8, spf: 57.0, online: 103.8\n",
      "清除Alpha\n",
      "cplex: 8.68, spf: 56.0, online: 83.8\n",
      "清除Alpha\n",
      "cplex: 9.9, spf: 46.4, online: 94.2\n",
      "清除Alpha\n",
      "cplex: 13.84, spf: 49.6, online: 82.4\n",
      "清除Alpha\n",
      "开始计算中继节点的Oblivious方案\n",
      "666\n",
      "cplex: 13.363636363636363, spf: 28.5, online: 82.4\n",
      "清除Alpha\n",
      "cplex: 6.868421052631579, spf: 40.333333333333336, online: 93.0\n",
      "清除Alpha\n",
      "cplex: 9.454545454545455, spf: 40.333333333333336, online: 97.8\n",
      "清除Alpha\n",
      "cplex: 11.083333333333334, spf: 27.0, online: 89.0\n",
      "清除Alpha\n",
      "cplex: 7.269230769230769, spf: 34.8, online: 94.8\n",
      "清除Alpha\n",
      "cplex: 8.4, spf: 44.166666666666664, online: 91.0\n",
      "清除Alpha\n",
      "cplex: 8.31578947368421, spf: 35.333333333333336, online: 84.0\n",
      "清除Alpha\n",
      "cplex: 8.7, spf: 37.8, online: 88.2\n",
      "清除Alpha\n",
      "cplex: 8.25, spf: 34.6, online: 88.2\n",
      "清除Alpha\n",
      "cplex: 9.5, spf: 25.2, online: 86.4\n",
      "清除Alpha\n",
      "cplex: 9.5625, spf: 25.8, online: 90.2\n",
      "清除Alpha\n",
      "cplex: 9.0, spf: 26.8, online: 81.0\n",
      "清除Alpha\n",
      "cplex: 9.444444444444445, spf: 30.333333333333332, online: 88.6\n",
      "清除Alpha\n",
      "cplex: 6.6923076923076925, spf: 19.8, online: 88.6\n",
      "清除Alpha\n",
      "cplex: 7.420330046804468, spf: 19.642857142857142, online: 95.0\n",
      "清除Alpha\n",
      "cplex: 9.375, spf: 46.0, online: 81.0\n",
      "清除Alpha\n",
      "cplex: 10.903225806451612, spf: 28.4, online: 84.6\n",
      "清除Alpha\n",
      "cplex: 7.235294117647059, spf: 30.857142857142858, online: 84.2\n",
      "清除Alpha\n",
      "cplex: 8.0, spf: 28.2, online: 113.0\n",
      "清除Alpha\n",
      "cplex: 11.67741935483871, spf: 28.2, online: 82.2\n",
      "清除Alpha\n",
      "开始计算中继节点的Oblivious方案\n",
      "666\n",
      "cplex: 8.64, spf: 86.33333333333333, online: 79.5\n",
      "清除Alpha\n",
      "cplex: 8.32, spf: 25.333333333333332, online: 67.16666666666667\n",
      "清除Alpha\n",
      "cplex: 6.806451612903226, spf: 52.625, online: 86.2\n",
      "清除Alpha\n",
      "cplex: 8.56, spf: 66.33333333333333, online: 84.4\n",
      "清除Alpha\n",
      "cplex: 8.5, spf: 78.66666666666667, online: 73.0\n",
      "清除Alpha\n",
      "cplex: 6.761904761904762, spf: 62.333333333333336, online: 74.33333333333333\n",
      "清除Alpha\n",
      "cplex: 7.826206157189283, spf: 66.66666666666667, online: 76.16666666666667\n",
      "清除Alpha\n",
      "cplex: 8.909090909090908, spf: 43.666666666666664, online: 80.2\n",
      "清除Alpha\n",
      "cplex: 8.095238095238095, spf: 56.5, online: 77.0\n",
      "清除Alpha\n",
      "cplex: 8.89795918367347, spf: 64.33333333333333, online: 78.0\n",
      "清除Alpha\n",
      "cplex: 8.548387096774194, spf: 77.0, online: 86.5\n",
      "清除Alpha\n",
      "cplex: 9.510204081632653, spf: 67.66666666666667, online: 73.0\n",
      "清除Alpha\n",
      "cplex: 8.428571428571429, spf: 48.833333333333336, online: 69.16666666666667\n",
      "清除Alpha\n",
      "cplex: 6.816326530612245, spf: 55.666666666666664, online: 79.16666666666667\n",
      "清除Alpha\n",
      "cplex: 10.294117647058824, spf: 82.16666666666667, online: 86.4\n",
      "清除Alpha\n",
      "cplex: 5.998349478013089, spf: 41.5, online: 77.4\n",
      "清除Alpha\n",
      "cplex: 6.836734693877551, spf: 58.666666666666664, online: 90.66666666666667\n",
      "清除Alpha\n",
      "cplex: 7.68, spf: 66.33333333333333, online: 69.8\n",
      "清除Alpha\n",
      "cplex: 9.137931034482758, spf: 40.0, online: 72.33333333333333\n",
      "清除Alpha\n",
      "cplex: 7.633661880413282, spf: 73.66666666666667, online: 82.2\n",
      "清除Alpha\n"
     ]
    }
   ],
   "source": [
    "from cluster_qkd_networkx_cluster import XMultiClusterQKDNetwork\n",
    "from tool import getGraphWithTemplateAndCapacity\n",
    "from itertools import combinations\n",
    "import numpy as np\n",
    "import random\n",
    "\n",
    "variable_node_nums_congestion_ratio = {\"Round\":[], \"SPS\":[], \"OGS\":[], \"ORDP\":[]} #拥塞率\n",
    "variable_node_nums_resource_utilization = {\"Round\":[], \"SPS\":[], \"OGS\":[], \"ORDP\":[]} #资源利用率\n",
    "variable_node_nums_jains_index = {\"Round\":[], \"SPS\":[], \"OGS\":[], \"ORDP\":[]} #公平性\n",
    "variable_capacity_congestion_ratio = {\"Round\":[], \"SPS\":[], \"OGS\":[], \"ORDP\":[]} #拥塞率\n",
    "variable_capacity_resource_utilization = {\"Round\":[], \"SPS\":[], \"OGS\":[], \"ORDP\":[]} #资源利用率\n",
    "variable_capacity_jains_index = {\"Round\":[], \"SPS\":[], \"OGS\":[], \"ORDP\":[]} #公平性\n",
    "\n",
    "_startClusterIDs = {}\n",
    "_endClusterIDs = {}\n",
    "startNodeIDs = {}\n",
    "endNodeIDs = {}\n",
    "cluster_number = 12\n",
    "sinle_cluster_size = 8\n",
    "\n",
    "for i in range(20):\n",
    "    if(i not in _startClusterIDs):\n",
    "        _startClusterIDs[i] = []\n",
    "        _endClusterIDs[i] = []\n",
    "        startNodeIDs[i] = []\n",
    "        endNodeIDs[i] = []\n",
    "    for j in range(1000):\n",
    "        _startClusterIDs[i].append(random.randint(1, cluster_number))\n",
    "        _endClusterIDs[i].append(random.randint(1, cluster_number))\n",
    "        startNodeIDs[i].append(random.randint(1, sinle_cluster_size))\n",
    "        endNodeIDs[i].append(random.randint(1, sinle_cluster_size))\n",
    "\n",
    "for round_idx in range(8):\n",
    "    template_number = 9\n",
    "\n",
    "    numbers = list(range(1, sinle_cluster_size*cluster_number+1))\n",
    "    nested_list = [numbers[i:i+sinle_cluster_size] for i in range(0, len(numbers), sinle_cluster_size)]\n",
    "    template_file_names = [f\"capacity_{round_idx*10+10}_cluster.txt\" for i in range(cluster_number)]\n",
    "    graph = getGraphWithTemplateAndCapacity(sinle_cluster_size, cluster_number, template_file_names, (round_idx+1)*10)\n",
    "    qkdnx = XMultiClusterQKDNetwork(\n",
    "        graph, \n",
    "        nested_list, \n",
    "        read_from_pkl=False, \n",
    "        read_from_template=True, #是否从pkl文件里面读XCluster\n",
    "        template_file_names=template_file_names\n",
    "    ) \n",
    "\n",
    "    if(round_idx!=0):\n",
    "        print(666)\n",
    "\n",
    "    cplex_alphas_total = []\n",
    "    spf_alphas_total = []\n",
    "    online_greedy_alphas_total = []\n",
    "\n",
    "    cplex_ru_total = []\n",
    "    spf_ru_total = []\n",
    "    online_greedy_ru_total = []\n",
    "\n",
    "    cplex_jains_index_total = []\n",
    "    spf_jains_index_total = []\n",
    "    online_greedy_jains_index_total = []\n",
    "\n",
    "    cplex_alphas = []\n",
    "    spf_alphas = []\n",
    "    online_greedy_alphas = []\n",
    "\n",
    "    cplex_ru = []\n",
    "    spf_ru = []\n",
    "    online_greedy_ru = []\n",
    "\n",
    "    cplex_jains_index = []\n",
    "    spf_jains_index = []\n",
    "    online_greedy_jains_index = []\n",
    "\n",
    "    for avg_round_idx in range(20):\n",
    "        cplex_alphas = []\n",
    "        spf_alphas = []\n",
    "        online_greedy_alphas = []\n",
    "\n",
    "        cplex_ru = []\n",
    "        spf_ru = []\n",
    "        online_greedy_ru = []\n",
    "\n",
    "        cplex_jains_index = []\n",
    "        spf_jains_index = []\n",
    "        online_greedy_jains_index = []\n",
    "\n",
    "        def generateBrokenLinkList() -> list:\n",
    "            broken_list = []\n",
    "            for node_ids in qkdnx.clusterListArr:\n",
    "                candidate_pair = []\n",
    "                if(len(node_ids)<3):\n",
    "                    continue\n",
    "                for u, v in combinations(node_ids, 2):\n",
    "                    if graph.has_edge(u, v):\n",
    "                        candidate_pair.append([u,v])\n",
    "                broken_list.append(candidate_pair[0] if len(candidate_pair) < 3 else candidate_pair[2])\n",
    "            return broken_list\n",
    "        \n",
    "        # 跑100轮，测均值\n",
    "        for i in range(1000):\n",
    "            qkdnx.requestFlow(\n",
    "                startClusterID = _startClusterIDs[avg_round_idx][i], \n",
    "                startNodeID = startNodeIDs[avg_round_idx][i], \n",
    "                endClusterID = _endClusterIDs[avg_round_idx][i], \n",
    "                endNodeID = endNodeIDs[avg_round_idx][i], \n",
    "                flow = random.randint(0, 50), \n",
    "                brokenLinks = generateBrokenLinkList(), \n",
    "            )\n",
    "\n",
    "        cplex_alphas.append(qkdnx.maxCplexAlpha)\n",
    "        spf_alphas.append(qkdnx.maxSPFAlpha)\n",
    "        online_greedy_alphas.append(qkdnx.maxOnlineGreedyAlpha)\n",
    "\n",
    "        ru_data = qkdnx.getResourceUtilization()\n",
    "        cplex_ru.append(ru_data[0])\n",
    "        spf_ru.append(ru_data[1])\n",
    "        online_greedy_ru.append(ru_data[2])\n",
    "\n",
    "        jain_index_data = qkdnx.getJainsIndex()\n",
    "        cplex_jains_index.append(jain_index_data[0])\n",
    "        spf_jains_index.append(jain_index_data[1])\n",
    "        online_greedy_jains_index.append(jain_index_data[2])\n",
    "\n",
    "        print(f\"cplex: {qkdnx.maxCplexAlpha}, spf: {qkdnx.maxSPFAlpha}, online: {qkdnx.maxOnlineGreedyAlpha}\")\n",
    "\n",
    "        qkdnx.setNetXFlowZero()\n",
    "        print(\"清除Alpha\")\n",
    "\n",
    "    cplex_alphas_total.append(np.mean(cplex_alphas))\n",
    "    spf_alphas_total.append(np.mean(spf_alphas))\n",
    "    online_greedy_alphas_total.append(np.mean(online_greedy_alphas))\n",
    "\n",
    "    cplex_ru_total.append(np.mean(cplex_ru))\n",
    "    spf_ru_total.append(np.mean(spf_ru))\n",
    "    online_greedy_ru_total.append(np.mean(online_greedy_ru))\n",
    "\n",
    "    cplex_jains_index_total.append(np.mean(cplex_jains_index))\n",
    "    spf_jains_index_total.append(np.mean(spf_jains_index))\n",
    "    online_greedy_jains_index_total.append(np.mean(online_greedy_jains_index))\n",
    "    \n",
    "    variable_node_nums_congestion_ratio[\"Round\"].append(cluster_number * sinle_cluster_size)\n",
    "    variable_node_nums_resource_utilization[\"Round\"].append(cluster_number * sinle_cluster_size)\n",
    "    variable_node_nums_jains_index[\"Round\"].append(cluster_number * sinle_cluster_size)\n",
    "\n",
    "    variable_node_nums_congestion_ratio[\"ORDP\"].append(np.mean(cplex_alphas_total))\n",
    "    variable_node_nums_congestion_ratio[\"SPS\"].append(np.mean(spf_alphas_total))\n",
    "    variable_node_nums_congestion_ratio[\"OGS\"].append(np.mean(online_greedy_alphas_total))\n",
    "\n",
    "    variable_node_nums_resource_utilization[\"ORDP\"].append(np.mean(cplex_ru_total))\n",
    "    variable_node_nums_resource_utilization[\"SPS\"].append(np.mean(spf_ru_total))\n",
    "    variable_node_nums_resource_utilization[\"OGS\"].append(np.mean(online_greedy_ru_total))\n",
    "\n",
    "    variable_node_nums_jains_index[\"ORDP\"].append(np.mean(cplex_jains_index_total))\n",
    "    variable_node_nums_jains_index[\"SPS\"].append(np.mean(spf_jains_index_total))\n",
    "    variable_node_nums_jains_index[\"OGS\"].append(np.mean(online_greedy_jains_index_total))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Round': [96, 96, 96, 96, 96, 96, 96, 96],\n",
       " 'SPS': [78.66666666666667,\n",
       "  56.2,\n",
       "  39.714285714285715,\n",
       "  41.55555555555556,\n",
       "  68.0,\n",
       "  49.6,\n",
       "  28.2,\n",
       "  73.66666666666667],\n",
       " 'OGS': [55.4, 65.8, 76.6, 95.4, 84.2, 82.4, 82.2, 82.2],\n",
       " 'ORDP': [36.9125180374671,\n",
       "  20.375,\n",
       "  20.59090909090909,\n",
       "  14.88888888888889,\n",
       "  10.76923076923077,\n",
       "  13.84,\n",
       "  11.67741935483871,\n",
       "  7.633661880413282]}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "variable_node_nums_congestion_ratio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Round': [96, 96, 96, 96, 96, 96, 96, 96],\n",
       " 'SPS': [0.10260367611729952,\n",
       "  0.08391881005779783,\n",
       "  0.09368160545135383,\n",
       "  0.07029174474116916,\n",
       "  0.03659936925594157,\n",
       "  0.046190027969003476,\n",
       "  0.06356878500916015,\n",
       "  0.02471240970821164],\n",
       " 'OGS': [0.21203877401020693,\n",
       "  0.11515214117886555,\n",
       "  0.07170732279105843,\n",
       "  0.063272625016487,\n",
       "  0.06160344272464015,\n",
       "  0.061267038978897743,\n",
       "  0.052398226490571014,\n",
       "  0.047422427413450756],\n",
       " 'ORDP': [0.23126025916823026,\n",
       "  0.23999383050347106,\n",
       "  0.1773123859747606,\n",
       "  0.18870965745319004,\n",
       "  0.20261698001340608,\n",
       "  0.13803324404052486,\n",
       "  0.15010997016248667,\n",
       "  0.20492368043608092]}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "variable_node_nums_resource_utilization"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Round': [96, 96, 96, 96, 96, 96, 96, 96],\n",
       " 'SPS': [0.45029087044947036,\n",
       "  0.4011052524182631,\n",
       "  0.33025414815321397,\n",
       "  0.36927530104322154,\n",
       "  0.2180274059840333,\n",
       "  0.2406076200236493,\n",
       "  0.315669038908303,\n",
       "  0.15927427298013963],\n",
       " 'OGS': [0.4836669518213937,\n",
       "  0.3234375283208618,\n",
       "  0.26539755908260165,\n",
       "  0.21569349295977625,\n",
       "  0.16884601761604556,\n",
       "  0.16962662403018994,\n",
       "  0.1632430348386579,\n",
       "  0.13530768815835956],\n",
       " 'ORDP': [0.6104622778529077,\n",
       "  0.599825747783375,\n",
       "  0.5666378439485507,\n",
       "  0.5770130479943439,\n",
       "  0.5885432990883562,\n",
       "  0.5709111771473581,\n",
       "  0.5489354190941155,\n",
       "  0.5615703851016414]}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "variable_node_nums_jains_index"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "cplex",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.1.undefined"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
